/* This code was modified by Georges Hanna Fab Academy 2018,NETWORKING AND COMMUNICATIONS The code was modified Based on the below codes : https://forum.arduino.cc/index.php?topic=386 https://maker.pro/arduino/tutorial/how-to-make-arduino-and-processing-ide-communicate */ #include //Include the software serial library in the sketch #define RxD 2 // Assign pin#2 on Attiny44 to be RX for receiving data ( This pin should be connected with the TX pin on Bluetooth module) #define TxD 1 // Assign pin#1 on Attiny44 to be TX for sending data( This pin should be connected with the RX pin on Bluetooth module) int LED = 7; // The led light is connected to Attiny44 pin # 7 SoftwareSerial BluetoothSerial(RxD, TxD); void setup() { BluetoothSerial.begin(9600); // Begin the bluetooth and set BaudRate to 9600 pinMode(LED,OUTPUT); pinMode(TxD, OUTPUT); // Telling Attiny44 to use TxD pin as an output pinMode(RxD, INPUT); // Telling Attiny44 to use RxD pin as an input } void loop() { BluetoothSerial.println(0); // Typing 0 every 6 seconds & this number will be sent to processing delay(3000); // Delay for 6 seconds char recvChar; // Define char datatype for reciving value from the blutooth device if(BluetoothSerial.available()){ //(If the connection is available recvChar = BluetoothSerial.read(); //Read the incoming data from processing if(recvChar == '1') // If the received data is 1 blink the led light { digitalWrite(LED,HIGH); // Turn on the led for half second delay (500); digitalWrite(LED,LOW); // Turn off the led for half second delay (500); } } }